home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / 386MOUSE.ASM < prev    next >
Assembly Source File  |  1995-01-12  |  7KB  |  231 lines

  1.  .386P
  2. code32 segment para public use32
  3.        assume cs:code32,ds:code32
  4.        
  5. include 386power.inc
  6.  
  7. ; Microsoft mouse interface
  8. ;  "real" mouse handler included into 386power
  9. ;  together with the "pseudo balistic" keyboard-mouse and joystick-mouse
  10. ;  emulators
  11.  
  12. hole  db 'XID: The selected mouse driver is not present',CR,LF,'$'
  13.  
  14. none: ; dummy entry
  15.         mov _386Return,offset hole
  16.         jmp _Exit
  17.         
  18. mickey  db 'MS-DOS MOUSE DRIVER (386P default)',0
  19.         ; offsets to asciiz containing mouse device name
  20.         ; (max 40 chars including the final NUL (0) byte )
  21.         
  22.         align dword
  23. _MouseName dd offset mickey, 0, 0, 0
  24.         ; mouse movement limits, they must be set before mouse positioning               
  25. _MouseX1 dd 4 dup(0)
  26. _MouseX2 dd 4 dup(0)
  27. _MouseY1 dd 4 dup(0)
  28. _MouseY2 dd 4 dup(0)
  29. _MouseZ1 dd 4 dup(0)
  30. _MouseZ2 dd 4 dup(0)
  31.         ; mouse stepping sensitivity
  32.         ; (controls ballistic/stepping if supported by driver)
  33. _MouseMX dd 4 dup(0)
  34. _MouseMY dd 4 dup(0)        
  35. _MouseMZ dd 4 dup(0)        
  36.         ; mouse coords  
  37.                       ; "low"        "high"
  38. _MouseX  dd 4 dup(0)  ; left     to right
  39. _MouseY  dd 4 dup(0)  ; up       to down
  40. _MouseZ  dd 4 dup(0)  ; backward to forward
  41. _AngXY   dd 4 dup(0)  ; right   to up
  42. _AngZY   dd 4 dup(0)  ; forward to up     
  43. _AngXZ   dd 4 dup(0)  ; right   to forward
  44. _Buttons dd 4 dup(0)  ; Mouse button flags
  45.                ; meaning of _Buttons
  46.                ; bit0 = button 0
  47.                ; bit1 = button 1
  48.                ; bit2 = button 3
  49.                ; ...
  50.                ; bitN = button N
  51.                ; YEAH! This baby can support up to 32 buttons
  52.                ; but usually a mouse will have 2..3 buttons
  53.                ; (duplicate the button3 function on the keyboard 
  54.                ;  if you wanna be safe)
  55.                ; If you duplicate button functions on the keyboard
  56.                ; you don't have to check the existence of buttons.
  57.                ; Anyway, if you own one of those weird mouse-with-keypad
  58.                ; you can fully use it once you get a XID driver.
  59.  
  60.         public _MouseX,_MouseY,_MouseZ,_AngXY,_AngZY,_AngXZ,_Buttons
  61.         public _MouseX1,_MouseX2,_MouseY1,_MouseY2,_MouseZ1,_MouseZ2
  62.         public _MouseMX,_MouseMY,_MouseMZ,_MouseName               
  63.  
  64.  
  65.                
  66. _MReset dd offset MMReset
  67.         dd offset none
  68.         dd offset none
  69.         dd offset none
  70.         
  71. _MRead  dd offset MMRead
  72.         dd offset none
  73.         dd offset none
  74.         dd offset none
  75.         
  76. _MWrite dd offset MMWrite
  77.         dd offset none
  78.         dd offset none
  79.         dd offset none
  80.         
  81. _MRange dd offset MMRange
  82.         dd offset none
  83.         dd offset none
  84.         dd offset none        
  85.         
  86. _MSetup dd offset MMSetup
  87.         dd offset none
  88.         dd offset none
  89.         dd offset none        
  90.         
  91.                 
  92.         
  93.         align byte
  94.         public _MouseReset
  95. _MouseReset:
  96.         ; in: esi = mouse device id
  97.         ; out:
  98.         ;    eax == 00000h if mouse not installed
  99.         ;    eax == 0FFFFh if mouse installed
  100.         ;             mouse hidden & positioned on center of screen
  101.         ;    coordinates not supported are set to 0
  102.         ;    angles not supported are set to -1
  103.         ;    the supported ones are initially set to zero
  104.         ;    all the mouse data vars must be set correctly before calling this
  105.         call [esi*4+_MReset]  ; reset
  106.         or eax,eax
  107.         jz theend
  108.         call [esi*4+_MRange]  ; set initial range
  109.         
  110.         mov eax,[esi*4+_MouseX2]
  111.         add eax,[esi*4+_MouseX1]
  112.         sar eax,1
  113.         mov [esi*4+_MouseX],eax
  114.         mov eax,[esi*4+_MouseY2]
  115.         add eax,[esi*4+_MouseY1]
  116.         sar eax,1
  117.         mov [esi*4+_MouseY],eax
  118.         call [esi*4+_MWrite]   ; write central position
  119.         
  120.         call [esi*4+_MRead]   ; & read it for safe
  121.         mov eax,0FFFFh
  122. theend:
  123.         ret        
  124.         
  125. MMReset: ; default mouse
  126.         mov V86eax,0
  127.         mov eax,33h
  128.         call _ExecINT
  129.         xor  eax,eax
  130.         mov [esi*4+_MouseZ],eax
  131.         mov eax,-1
  132.         mov [esi*4+_AngXY],eax
  133.         mov [esi*4+_AngZY],eax
  134.         mov [esi*4+_AngXZ],eax
  135.         mov eax,V86eax
  136.         ret
  137.         
  138.         public _MouseRead
  139. _MouseRead:        
  140.         jmp [esi*4+_MRead]
  141.         ; mouse status vars set
  142.         
  143. MMRead: push eax
  144.         push ecx
  145.         push ebx
  146.         mov V86eax,3 ; poll current mouse buttons & position
  147.         ; OUT:
  148.         ;       V86bx = button status
  149.         ;               bit0 = 1 if LEFT  button pressed
  150.         ;               bit1 = 1 if RIGHT button pressed
  151.         ;       V86cx = column
  152.         ;       V86dx = row
  153.         mov al,33h
  154.         call _ExecINT
  155.         mov   eax,V86ebx
  156.         movsx ecx,V86cx
  157.         and eax,7 ; up to three buttons supported in microsoft mouse mode
  158.         movsx ebx,V86dx
  159.         mov [esi*4+_Buttons],eax
  160.         mov [esi*4+_MouseX],ecx
  161.         mov [esi*4+_MouseY],ebx
  162.         pop ebx
  163.         pop ecx
  164.         pop eax
  165.         ret
  166.         
  167.         public _MouseWrite
  168. _MouseWrite:
  169.         jmp [esi*4+_MWrite]
  170.         
  171. MMWrite:push eax
  172.         push ebx
  173.         push ecx
  174.         mov V86eax,4 ; set mouse pointer position
  175.         ;  IN: V86cx = new column
  176.         ;      V86dx = new row
  177.         ;  N.B. depending on the video mode some mouse drivers
  178.         ;       either TRUNC or ROUND the row/column values received
  179.         mov ecx,[esi*4+_MouseX]
  180.         mov ebx,[esi*4+_MouseY]
  181.         mov V86ecx,ecx
  182.         mov V86edx,ebx
  183.         mov al,33h
  184.         call _ExecINT
  185.         pop ecx
  186.         pop ebx
  187.         pop eax
  188.         ret
  189.         
  190.         public _MouseRange
  191. _MouseRange:
  192.         jmp [esi*4+_MRange]
  193.         
  194. MMRange: ; sets ranges, and balistic/stepping of movements
  195.         push eax
  196.         push ebx
  197.         push ecx
  198.         ; X Range
  199.         mov V86eax,7
  200.         mov ecx,[esi*4+_MouseX1]
  201.         mov ebx,[esi*4+_MouseX2]
  202.         mov V86ecx,ecx
  203.         mov V86edx,ebx
  204.         ; IN: V86cx = min column
  205.         ;     V86dx = max column
  206.         mov al,33h
  207.         call _ExecINT
  208.         ; Y Range
  209.         mov V86eax,8
  210.         mov ecx,[esi*4+_MouseY1]
  211.         mov ebx,[esi*4+_MouseY2]
  212.         mov V86ecx,ecx
  213.         mov V86edx,ebx
  214.         ; IN: V86cx = min row
  215.         ;     V86dx = max row
  216.         mov al,33h
  217.         call _ExecINT
  218.         pop ecx
  219.         pop ebx
  220.         pop eax
  221.         ret
  222.         
  223.         public _MouseSetup
  224. _MouseSetup:
  225.         jmp [esi*4+_MSetup]        
  226.         
  227. MMSetup: ret ; this one needs no setups
  228.        
  229. code32 ends        
  230.        END
  231.